﻿@{
    int? typeCode = null;
    if (!string.IsNullOrEmpty(Convert.ToString(ViewData["TypeCode"])))
    {
        typeCode = ViewData["TypeCode"] as int?;
    }
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>资源共享</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav.cshtml")
    <div class="container wrap">
        <div class="row">
            <h1 class="topTitle-h1">康复治疗微课程网络学习平台
                <br>
                <small>广州中医药大学针灸康复临床医学院</small>
            </h1>
        </div>
    </div>
   @* @Html.Partial("~/Views/Share/PublicNav.cshtml")*@
    <div class="wrap container mainwrap">
        <div class="row">
            <div class="col-xs-9 ">
                <div class="lBox part mainwrap-part">
                    <div class="lBox-th">
                        <h3>资源下载</h3>
                    </div>
                    <div class="lBox-tb">
                        <div class="row">
                            <div class="col-xs-3">
                                @Html.DropDownList("CourseId", CourseInfoManage.Instance.CourseInfos, "", new { @class = "form-control" })
                            </div>
                            <div class="col-xs-7">
                                <input type="text" class="form-control" id="searchTitleTxt" placeholder="">
                            </div>
                            <div class="col-xs-2 text-right">
                                <button type="button" onclick="getList(1)" class="btn btn-success btn-md">
                                    <span class="glyphicon glyphicon-search"></span>
                                    搜索
                                </button>
                            </div>
                        </div>
                        <div class="search-th">
                            <strong>找到相关资源<span id="resourceCount"></span>个</strong>
                        </div>
                        <ul id="myTab" class="nav nav-tabs">
                            <li class="@(typeCode == null ? "active" : "")" onclick="tabClick('');">
                                <a href="#all" data-toggle="tab" aria-expanded="true">全部</a>
                            </li>

                            <li class="@(typeCode == 1001 ? "active" : "")" onclick="tabClick('1001');">
                                <a href="#jxzy" data-toggle="tab" aria-expanded="false">教学资源</a>
                            </li>
                            <li class="@(typeCode == 1002 ? "active" : "")" onclick="tabClick('1002');">
                                <a href="#sypt" data-toggle="tab" aria-expanded="false">实验平台</a>
                            </li>
                            <li class="@(typeCode == 1003 ? "active" : "")" onclick="tabClick('1003');">
                                <a href="#zygx" data-toggle="tab" aria-expanded="false">资源共享</a>
                            </li>

                        </ul>
                        <div id="myTabContent" class="tab-content pt5 mb15">
                            <div class="tab-pane fade active in">
                                <table class="table table-bordered table-hover table-striped zy-table">
                                    <thead>
                                        <tr>
                                            <th width="30%">标题</th>
                                            <th width="45%">文件名</th>
                                            <th width="15%">上传时间</th>
                                            <th width="10%">操作选项</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tbody">
                                    </tbody>
                                </table>
                            </div>
                            <div class="row clearfix well d-page">
                                <div id="PagInfo" class="pull-left sum">
                                </div>
                                <div class="clearfix pull-right">
                                    <ul id="PageTool" class="pagination">
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-3">
                @Html.Partial("~/Views/Share/PublicRBox.cshtml")
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script>
        var tbody = $("#tbody");
        var options = false;
        var _state = false;
        var _typeCode = "@typeCode";
        function getList(pageNo) {

            $("#PagInfo").html("");
            $("#PageTool").html("");

            var _courseId = $("#CourseId").val();
            var _title = $("#searchTitleTxt").val();

            $.easyPost("/ResourceInfo/GetResourceInfoList", { "PageNO": pageNo, "PageSize": "10", "CourseId": _courseId, "TypeCode": _typeCode, "Title": _title },
               function (data) {
                   if (!data.result) {
                       showTips.open(data.message);
                       return;
                   }
                   var _html = '';
                   if (data.rows.length > 0) {
                       $(".d-page").show();
                       $("#resourceCount").html(data.total);
                       var _row = data.rows,
                           _rowL = _row.length;
                       options = {
                           totalPages: data.totalPage,
                           total: data.total,
                           currentPage: pageNo,
                           onPageClicked: function (event, originalEvent, type, page) {
                               getList(page);
                           }
                       }
                       initialPaginator(options, "PageTool", "PagInfo");

                       for (var i = 0; i < _rowL; i++) {
                           var item = _row[i];
                           var _date = item.CreateTime.toString().replace(/\//g, "");
                           var time = eval('new ' + _date);
                           _html += "<tr>";
                           _html += "<td>" + item.Title + "</td>";
                           _html += "<td>" + item.FileName + "</td>";
                           _html += "<td>" + time.format('yyyy-MM-dd') + "</td>";
                           _html += "<td>";
                           _html += "<a href='@WebSiteDomain.ResFileDomain"  + item.FilePath + "'>下载</a>";
                           _html += "</td>";
                           _html += "</tr>";
                       }
                   }
                   else {
                       _html = "<tr><td colspan='4' align='center'>暂无内容!</tr>";
                       $("#resourceCount").html("0");
                       $(".d-page").hide();
                   }
                   tbody.html(_html)
               }, "json");
           }


           if (!!window.location.hash) {
               var _hash = window.location.hash.substr(1);
               getList(_hash);
           } else {
               getList(1);
           }



           function tabClick(typeCode) {
               _typeCode = typeCode;

               //初始化搜索条件
               $("#CourseId").val("");
               $("#searchTitleTxt").val("");
               getList(1);
           }


    </script>
</body>
</html>
